﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using System.Windows.Data;

namespace CoreModule.Converters
{
    public class NotDeviceDoubleValueToStringConverter : IValueConverter
    {
        /// <summary>
        /// 
        /// </summary>
        public string Placeholder { get; set; } = "-";

        public string Formart { get; set; } = "F1";

        /// <summary>
        /// 
        /// </summary>
        /// <param name="value"></param>
        /// <param name="targetType"></param>
        /// <param name="parameter"></param>
        /// <param name="culture"></param>
        /// <returns></returns>
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {

            var f = (double)value;

            ///这个固定值
            if (f == CoreConstant.NotDevice)
            {
                return Placeholder;
            }
            else
            {
                return f.ToString(Formart);
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
